From: Marco Trevisan (TreviƱo) Date: Fri, 5 Dec 2025 22:39:23 +0000 (+0100) Subject: environment: Split out the prepare and cleanup animation code X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~44^2~47 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=7aacc1cab033fd77370b8d03b037892b3dd28a7f;p=gnome-shell.git environment: Split out the prepare and cleanup animation code We do the same twice, and it's not trivial code anymore, so let's separate this into another function which returns the prepare and cleanup functions Part-of: --- diff --git a/js/ui/environment.js b/js/ui/environment.js index 8effcd240..64a2b4629 100644 --- a/js/ui/environment.js +++ b/js/ui/environment.js @@ -71,6 +71,19 @@ function _makeEaseCallback(params, cleanup) { }; } +function _makeEasePrepareAndCleanup() { + const prepare = () => { + global.compositor.disable_unredirect(); + global.begin_work(); + }; + const cleanup = () => { + global.compositor.enable_unredirect(); + global.end_work(); + }; + + return {prepare, cleanup}; +} + function _getPropertyTarget(actor, propName) { if (!propName.startsWith('@')) return [actor, propName]; @@ -128,14 +141,7 @@ function _easeActor(actor, params) { actor.set_easing_mode(params.mode); delete params.mode; - const prepare = () => { - global.compositor.disable_unredirect(); - global.begin_work(); - }; - const cleanup = () => { - global.compositor.enable_unredirect(); - global.end_work(); - }; + const {prepare, cleanup} = _makeEasePrepareAndCleanup(); const callback = _makeEaseCallback(params, cleanup); // cancel overwritten transitions @@ -209,14 +215,7 @@ function _easeAnimatableProperty(animatable, propName, target, params) { if (!actor?.mapped) duration = 0; - const prepare = () => { - global.compositor.disable_unredirect(); - global.begin_work(); - }; - const cleanup = () => { - global.compositor.enable_unredirect(); - global.end_work(); - }; + const {prepare, cleanup} = _makeEasePrepareAndCleanup(); const callback = _makeEaseCallback(params, cleanup); // cancel overwritten transition